$(document).ready(function(){
    findPlanStartStandard();
    
//    $('#next').click(function(){
//        //window.location.href = "zhzrm.jsp";
//		//alert("gggggggg");
//		//redirectPage("/ag/lzm/start_plan4s.jsp");
//		//window.location.href = "/ag/lzm/start_plan4s.jsp";
//		var elId=$("input[type='radio']:checked").val();
//		if(elId==undefined){
//			alert("请选择预案启动标准！");
//			return;
//		}else{
//			savePlanStartStandard(elId);
//		}		
//    });
    $('#next').click(function(){
    	if($("input:checked").length != 0){
    		
    		/* czy stard 把预案原因增加到Tbevent表里面。 */
    		    var t_area=$("#t_area").attr("value");
    		  	var url_saveTextArea = 'dgm/saveTextArea_AdviceType.action';
    			var t_area_data={
    					'textarea':t_area
    			};
    			$.post(url_saveTextArea,t_area_data,function(data){
    			});
    	    /*    czy end   */
    			
    	var str="";
    		$("input:checked").each(function(){
    			str=str+$(this).val()+",";
    		});
    			//alert(str);
    			var url_savePlanStartStandard = 'work2/LZMPlanStartStandard_savePlanStartStandard.action';
    			var req={
    					'elidsString':str
    			};
    			$.post(url_savePlanStartStandard,req,function(data){
//    					alert(data.ajaxRst);
//    					window.location.href="/ag/lzm/start_plan4s.jsp";
    					var planLevel=$.trim($("#planLevel").text());
//    				   window.location.href="/ag/lzm/start_plan4s.jsp?planLevel="+planLevel;		//进入预案选择界面
    					window.location.href="/ag/work/planSelect.jsp?planLevel=1";
    			});
    			}else{
    				alert("请至少选择一个启动原因");
    			}
    		});
    $('#back').click(function(){
    	window.location.href="/ag/work/reportTable.jsp";
    });
    
    
    });
/**
 * 取checkbox的值
 */
/**
 * 实现页面的定向
 * @param url 传入定向的目标URL
 */
function redirectPage(url){
   $('#mainFrame', window.parent.document).attr("src", url);
}
/**
 * 作保存所有预案等级操作
 */
function savePlanStartStandard(elId){	
    var timestamp = Date.parse(new Date());
    var url = 'work2/LZMPlanStartStandard_savePlanStartStandard.action';
    var params = {
        'timestamp': timestamp,
		'elId':elId
    };
    jQuery.post(url, params, savePlanStartStandardRst, 'json');
}
/**
 * 作保存预案启动标准回调函数
 */
function savePlanStartStandardRst(data){
    if (data.ajaxRst == "success") {
       //redirectPage("/ag/lzm/start_plan4s.jsp");
    	var planLevel=$.trim($("#planLevel").text());
    	//alert(planLevel);
	   window.location.href="/ag/lzm/start_plan4s.jsp?planLevel="+planLevel;		//进入预案选择界面
    }
    else {
        alert("服务器异常，请重试！");
    }
}

/**
 * 作获取所有预案等级操作
 */
function findPlanStartStandard(){
//	alert($('#planLevel').text());
    var timestamp = Date.parse(new Date());
    var url = 'work2/LZMPlanStartStandard_findPlanStartStandard.action';
    var params = {
        'timestamp': timestamp,
        'planLevel': $('#planLevel').text()
    };
    jQuery.post(url, params, findPlanStartStandardRst, 'json');
}

/**
 * 作获取事件类型回调函数
 */
function findPlanStartStandardRst(data){
    if (data.ajaxRst == "success") {
        $.each(data.planStandards, function(i, n){
            var tempObjTR1 = null;
            tempObjTR1 = $("#triddiv").clone(true);
            tempObjTR1.find('.standardContent').html(n.PContent);
			tempObjTR1.find('.EEntry').html(n.EEntry);
			tempObjTR1.find('.psradio').val(n.elId);
            $('#standardTB').append(tempObjTR1);
        });
    }
    else {
        alert("服务器异常，请重试！");
    }
}